package com.eastfair.certificate.enumeration;

import com.eastfair.annotation.base.BaseEnum;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.Getter;

import java.util.stream.Stream;

/**
 * <p>
 * 实体注释中生成的类型枚举
 * 证件指标设置
 * </p>
 *
 * @author ligang
 * @date 2022-10-12
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "CertificateIndexClassifyEnum", description = "证件分类:#{ARRANGE:布展证;MOVEOUT:撤展证;-枚举")
public enum CertificateIndexClassifyEnum implements BaseEnum {

    /**
     * ARRANGE="布展证"
     */
    ARRANGE("布展证"),
    /**
     * MOVEOUT="撤展证"
     */
    MOVEOUT("撤展证"),
    ;

    @ApiModelProperty(value = "描述")
    private String desc;


    /**
     * 根据当前枚举的name匹配
     */
    public static CertificateIndexClassifyEnum match(String val, CertificateIndexClassifyEnum def) {
        return Stream.of(values()).parallel().filter(item -> item.name().equalsIgnoreCase(val)).findAny().orElse(def);
    }

    public static CertificateIndexClassifyEnum get(String val) {
        return match(val, null);
    }

    public boolean eq(CertificateIndexClassifyEnum val) {
        return val != null && eq(val.name());
    }

    @Override
    @ApiModelProperty(value = "编码", allowableValues = "ARRANGE,MOVEOUT", example = "ARRANGE")
    public String getCode() {
        return this.name();
    }

}
